<template>
    <div>
        <van-form @submit="onSubmit">
            <van-cell-group inset>
                <van-field
                v-model="username"
                name="用户名"
                label="用户名"
                placeholder="用户名"
                :rules="[{ required: true, message: '请填写用户名' }]"
                />
                <van-field
                v-model="password"
                type="password"
                name="密码"
                label="密码"
                placeholder="密码"
                :rules="[{ required: true, message: '请填写密码' }]"
                />
                <van-field
                v-model="sms"
                center
                clearable
                label="短信验证码"
                placeholder="请输入短信验证码">
                <template #button>
                <van-button size="small" type="primary">发送验证码</van-button>
                </template>



            </van-field>

            </van-cell-group>
            <div style="margin: 16px;">
                <van-button round block type="primary" native-type="submit">
                登录
                </van-button>
            </div>
        </van-form>

    </div>
</template>
<script>
import {reactive,ref,toRefs} from 'vue'
import { useRouter,useRoute } from 'vue-router'
export default {
    setup(){
        const router = useRouter //整个router对象
		const route  = useRoute  //当前路由对象 
        const obj = reactive({
            username: '',
            password: '',
            sms: '' ,
        })
        const onSubmit = () => {
            console.log('登录')
            sessionStorage.setItem('token', JSON.stringify({
                username: 'kerwin',
                userId: 123456,
            }))
        }
       
        return {
            ...toRefs(obj),
            onSubmit,
        }
    }
}
</script>